package com.thd.example.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.thd.example.entity.ThdFramesetExampleEntity;
import com.thd.example.entity.ThdFramesetExampleVO;
import com.thd.example.service.ThdFramesetExampleService;
import com.thd.framework.basic.model.Message;
import com.thd.framework.web.controller.BasicController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * @author
 **/
@RestController
@RequestMapping("/thdFramesetExample")
@Api(value = "thdFramesetExample表基础CRUD接口", description = "thdFramesetExample表基础CRUD接口")
public class ThdFramesetExampleController extends BasicController {

	@Autowired
	private ThdFramesetExampleService thdFramesetExampleService;

	@ApiOperation(value = "[创建]ThdFramesetExample")
	@PostMapping("/createThdFramesetExample")
	public Message<ThdFramesetExampleEntity> createThdFramesetExample(@RequestBody ThdFramesetExampleEntity thdFramesetExample) {
		thdFramesetExampleService.createThdFramesetExample(thdFramesetExample);
		return success(thdFramesetExample);
	}

	@ApiOperation(value = "[更新]根据id更新ThdFramesetExample")
	@PostMapping("/modifyThdFramesetExample")
	public Message<ThdFramesetExampleEntity> modifyThdFramesetExample(@RequestBody ThdFramesetExampleEntity thdFramesetExample) {
		thdFramesetExampleService.modifyThdFramesetExample(thdFramesetExample);
		return success(thdFramesetExample);
	}

	@ApiOperation(value = "[创建/更新]创建或更新ThdFramesetExample",notes = "id有值则为更新,id无值则为创建")
	@PostMapping("/saveOrUpdateThdFramesetExample")
	public Message<ThdFramesetExampleEntity> saveOrUpdateThdFramesetExample(@RequestBody ThdFramesetExampleEntity thdFramesetExample) {
		thdFramesetExampleService.saveOrUpdateThdFramesetExample(thdFramesetExample);
		return success(thdFramesetExample);
	}

	@ApiOperation(value = "[删除]根据id删除ThdFramesetExample")
	@GetMapping("/deleteThdFramesetExampleById/{id}")
	public Message<Boolean> deleteThdFramesetExampleById(@PathVariable String id) {
		thdFramesetExampleService.deleteThdFramesetExampleById(id);
		return success(true);
	}



	@ApiOperation(value = "[查询]根据id查询ThdFramesetExample")
	@GetMapping("/queryThdFramesetExampleById/{id}")
	public Message<ThdFramesetExampleEntity> queryThdFramesetExampleById(@PathVariable String id) {
		return success(thdFramesetExampleService.queryThdFramesetExampleById(id));
	}

	@ApiOperation(value = "[查询]查询ThdFramesetExample")
	@PostMapping("/queryList")
	public Message<List<ThdFramesetExampleVO>> addThdFramesetExample(@RequestBody ThdFramesetExampleVO thdFramesetExampleVO) {
		List l = thdFramesetExampleService.queryThdFramesetExample(thdFramesetExampleVO);
		return success(l);
	}

	@ApiOperation(value = "[查询]分页查询ThdFramesetExample")
	@PostMapping("/queryListByPage")
	public Message<PageInfo<ThdFramesetExampleVO>> queryListByPage(@RequestBody ThdFramesetExampleVO thdFramesetExampleVO) {
		PageInfo r = thdFramesetExampleService.queryThdFramesetExamplePage(thdFramesetExampleVO);
		return success(r);
	}

	@ApiOperation(value = "[查询]分页查询ThdFramesetExample")
	@PostMapping("/queryListMpByPage")
	public Message<PageInfo<ThdFramesetExampleVO>> queryListMpByPage(@RequestBody ThdFramesetExampleVO thdFramesetExampleVO) {
		IPage<ThdFramesetExampleVO> page =new Page<>(thdFramesetExampleVO.getPageNum(),thdFramesetExampleVO.getPageSize());
		thdFramesetExampleService.pageJoinQuery(page,thdFramesetExampleVO);
		return success(page);
	}


}

